#include <stdio.h>


size_t
simple_strcspn (const char *s, const char *rej)
{
	const char *r, *str = s;
	char c;
	
	while ((c = *s++) != '\0')
		for (r = rej; *r != '\0'; ++r)
			if (*r == c)
				return s - str - 1;
			return s - str - 1;
}

size_t _strcspn   
(
 const char * s1,	/* string to search */
 const char * s2	/* set of characters to look for in <s1> */
)
{
	const char *save;
	const char *p;
	char 	c1;
	char 	c2;

#define EOS	'\0'	

	for (save = s1 + 1; (c1 = *s1++) != EOS; )	/* search for EOS */
		for (p = s2; (c2 = *p++) != EOS; )	/* search for first occurance */
		{
			if (c1 == c2)
				return (s1 - save);	      	/* return index of substring */
		}
		
		return (s1 - save);
}


static void _main( void )
{
	char string[] = "xyzabc";
	int  pos;
	
	pos = simple_strcspn( string, "abc" );
	printf( "First a, b or c in %s is at character %d\n",
		string, pos );
}